package com.shujia.sql

import org.apache.spark.sql.{DataFrame, SparkSession}

object Demo4Show {
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession
      .builder()
      .master("local")
      .appName("api")
      .getOrCreate()


    val studentsDF: DataFrame = spark
      .read
      .format("csv")
      .option("sep", ",") //默认分割方式是逗号
      .schema("id STRING, name STRING , age INT ,gender STRING ,clazz STRING")
      .load("data/students.txt")

    //默认取前20
    studentsDF.show()

    //指定获取的行数
    studentsDF.show(100)

    //完全显示数据
    studentsDF.show(100, false)
  }

}
